import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

/**
 * Write a description of class Pin here.
 * 
 * @author Christian Pérez Zavalija
 * @version 25-Jun-2013
 */
public class Pin extends Actor
{
    private GreenfootImage img;
    protected int charge;
    
    /**
     * Creates a pin of a specified size and assigns a trash charge.
     * 
     * @param aSize a Size.
     */
    public Pin(int aSize)
    {
        img=new GreenfootImage(aSize,aSize);
        //img.fill();
        setImage(img);
        charge=2;
    }
    
    /**
     * changes the charge for a new.
     * 
     * @param newCharge A new charge. 
     */
    public int setCharge(int newCharge)
    {
        return charge=newCharge;
    }
    
    /**
     * Verify the charge.
     */
    public int getCharge()
    {
        return charge;
    }
    
    /**
     * Know when you make a click to a pin, and summon the pinSelecc method of the canvas.
     */
    public void act() 
    {
        if(Greenfoot.mouseClicked(this)){
            World world=getWorld();
            Canvas canvas=(Canvas)world;
            canvas.pinSelecc(this);
        }
    }
    
    /**
     * The image is scale in 100%
     */
    public void scale()
    {
        img.scale(img.getWidth(),img.getHeight());
    }
}
